-
Notifications
You must be signed in to change notification settings - Fork 40
Add DCSR and DPC CSRs #614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add DCSR and DPC CSRs #614
Conversation
For core debug registers like DCSR and DPC, it’s stated that “these registers are only accessible from Debug Mode” (Section 4.9, debug specs). What would be the correct priv_mode for those CSRs? Debug mode isn’t one of the options in the schema (only M, S, U, VS). |
Hmm. The Priv spec 1.3 "Debug Mode" says:
That sounds like a full Mode (capital M). It probably needs to be treated as such, adding a new mode in Some additional information:
These 3 bits appear to be the concatenation of MPV and MPP, or at least they line up that way in the Priv spec, 18.4.1 "Machine Status Registers (mstatus and mstatush)", table 32: It may be that you could just pick a random new enum value (prepend a 4th bit, like |
Yea, we do need to add D-mode in globals.isa, and yes, there are cases where we are relying on the encoding of PrivilegeMode being the table Paul added above. For example: riscv-unified-db/arch/isa/globals.isa Lines 628 to 634 in 00f1540
As such, we should encode D as 0b1011 since it is M (0b0011) with extra permission. |
arch/csr/dpc.yaml
Outdated
long_name: Debug PC Register | ||
address: 0x7B1 | ||
priv_mode: D | ||
length: XLEN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need a "DXLEN" here. From The RISC-V Debug Specification:
DXLEN: Debug XLEN, which is the widest XLEN a hart supports, ignoring the current value of MXL in
misa
.
Also, needs to be added to schemas/csr_schema.json
as a valid enum.
arch/csr/dpc.yaml
Outdated
location_rv32: 31-0 | ||
location_rv64: 63-0 | ||
type: RW | ||
description: DPC Value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change "DPC" to "Debug PC"
arch/csr/dcsr.yaml
Outdated
if (!MPRVEN_IMPLEMENTED) { | ||
unimplemented_csr($encoding); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add return of the value to be written:
return csr_value.MPRVEN;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given this statement:
"Implementing this bit is optional. It may be tied to either 0 or 1."
I think the behavior is that the bit always "exists"/won't cause an exception. Rather, it can be:
- tied to 0
- tied to 1
- R/W
So, I think the parameter needs to enumerate those possibilities, and based on that, we need a dynamic type()
/reset_value()
. Since sw_write()
doesn't apply to Read-Only bits, and when it is writable there are no restrictions, we don't actually need sw_write()
.
One of the regression tests is failing:
Might need a hint from @dhower-qc here, but adding DXLEN support might also include:
|
arch/csr/dcsr.yaml
Outdated
if (!MPRVEN_IMPLEMENTED) { | ||
unimplemented_csr($encoding); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given this statement:
"Implementing this bit is optional. It may be tied to either 0 or 1."
I think the behavior is that the bit always "exists"/won't cause an exception. Rather, it can be:
- tied to 0
- tied to 1
- R/W
So, I think the parameter needs to enumerate those possibilities, and based on that, we need a dynamic type()
/reset_value()
. Since sw_write()
doesn't apply to Read-Only bits, and when it is writable there are no restrictions, we don't actually need sw_write()
.
The regressions are failing because of the various places we've assumed that MXLEN is the fundamental XLEN of the machine. We either need to fix that, or... I wonder if DXLEN can ever be > than MXLEN? The spec states that DXLEN is:
That seems to be accounting for the fact that misa.MXL used to be mutable. But the spec was amended to make that impossible. As such, I have trouble imagining any use for a machine where MXLEN == 32 and DXLEN == 64. And it's not worth implementing a DXLEN > MXLEN for the old spec where misa.MXL could change, since the assumption is there are zero implementations out there that do it (it was never well-enough defined anyway). My vote is to drop DXLEN, and get clarification from the debug spec that DXLEN is always identical to MXLEN. |
Per Paul Donahue (Ventana, author of the Debug spec):
|
Thanks for the feedback! I'll remove the DXLEN code and use MXLEN for |
Excellent. That's going save us a few headaches. |
This PR addresses Issue #570 and adds the remaining missing debug CSRs